package lukeer.fencing;

/**
 * A board holds a collection of Piece objects which are also held in sectors. Pieces hold a piece type and fence
 * information.
 * User: Luke Richardson, Wafa M'Barek
 * Date: 17/09/12
 * Time: 16:57
 */
public class BoardPiece implements csproj.fencing.Piece {
    private int type;
    private boolean vFence;
    private boolean hFence;
    private final int x;
    private final int y;

    public BoardPiece(int x, int y) {
        this.x = x;
        this.y = y;
        type = EMPTY;
        vFence = false;
        hFence = false;
    }

    /**
     * Deep copy constructor
     *
     * @param p piece to be copied
     */
    public BoardPiece(BoardPiece p) {
        this.x = p.getX();
        this.y = p.getY();
        type = p.getType();
        vFence = p.getVFence();
        hFence = p.getHFence();
    }

    /**
     * Get type of piece either BLACK, WHITE or EMPTY
     *
     * @return int value of piece type
     */
    public int getType() {
        return this.type;
    }

    /**
     * Set value of piece either BLACK, WHITE or EMPTY
     *
     * @param type int value of piece type
     */
    public void setType(int type) {
        this.type = type;
    }

    /**
     * Getter for vertical fence
     *
     * @return true if fence exists
     */
    public boolean getVFence() {
        return vFence;
    }

    /**
     * Setter for vertical fence
     */
    public void setVFence() {
        this.vFence = true;
    }

    /**
     * Getter for horizontal fence
     *
     * @return true if fence exists
     */
    public boolean getHFence() {
        return hFence;
    }

    /**
     * Setter for horizontal fence
     */
    public void setHFence() {
        this.hFence = true;
    }

    /**
     * Return x value of piece position
     *
     * @return x position on board
     */
    public int getX() {
        return x;
    }

    /**
     * Return y value of piece position
     *
     * @return y position on board
     */
    public int getY() {
        return y;
    }
}

